//
//  GYNewShopTopCell.m
//  GYDemo
//
//  Created by Mrzhang on 2018/6/27.
//  Copyright © 2018年 mac. All rights reserved.
//

#import "GYNewShopTopCell.h"
#import "Head.h"
@interface GYNewShopTopCell ()<SDCycleScrollViewDelegate>
@property(nonatomic,strong)UILabel* titleLab;
@property(nonatomic,strong)UILabel* DealCountLab;
@property(nonatomic,strong)SDCycleScrollView* bannerScroll;
@property(nonatomic,strong)UIImageView* lineIV;
@property(nonatomic,strong)UIButton* shareBtn;
@property(nonatomic,strong)UIView* levelView;
@property(nonatomic,strong)UILabel* levelLab;
@end;

@implementation GYNewShopTopCell

#pragma mark setter getter
-(UILabel *)levelLab
{
    if (!_levelLab) {
        _levelLab=[[UILabel alloc] init];
        _levelLab.textColor=HEXCOLOR(@"#666666");
        _levelLab.font=SYSTEMFONT(13);
        _levelLab.x=WFCGFloatX(19);
        _levelLab.y=WFCGFloatY(245);
        _levelLab.width=WFCGFloatX(41);
        _levelLab.height=19;
        _levelLab.text=@"信誉:";
        
    }
    return _levelLab;
}
-(UIView *)levelView
{
    if (!_levelView) {
        _levelView=[UIView new];
        _levelView.x=WFCGFloatX(63);
        _levelView.y=WFCGFloatY(245);
        _levelView.width=WFCGFloatX(150);
        _levelView.height=19;
    }
    return _levelView;
}
-(SDCycleScrollView *)bannerScroll
{
    if (!_bannerScroll) {
        _bannerScroll=[SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, WFCGFloatY(203)) delegate:self placeholderImage:DefaultImage];
        _bannerScroll.backgroundColor=Main_Color_BGLightGray;
        _bannerScroll.currentPageDotColor=Main_Color_Red;
        _bannerScroll.pageDotColor=RGBACOLOR(216, 216, 216, 0.5);
        _bannerScroll.bannerImageViewContentMode=UIViewContentModeScaleAspectFill;
    }
    return _bannerScroll;
}
-(UILabel *)titleLab
{
    if (!_titleLab) {
        _titleLab=[[UILabel alloc] init];
        _titleLab.textColor=Main_Color_Black;
        _titleLab.font=SYSTEMFONT(15);
        
    }
    return _titleLab;
}

-(UIImageView *)lineIV
{
    if (!_lineIV) {
        _lineIV=[[UIImageView alloc] init];
        _lineIV.x=WFCGFloatX(312);
        _lineIV.y=WFCGFloatY(232);
        _lineIV.width=2;
        _lineIV.height=20;
        _lineIV.backgroundColor=HEXCOLOR(@"#979797");
    }
    return _lineIV;
}

-(UILabel *)DealCountLab
{
    if (!_DealCountLab) {
        _DealCountLab=[[UILabel alloc] init];
        _DealCountLab.textColor=HEXCOLOR(@"#666666");
        _DealCountLab.font=SYSTEMFONT(12);
        _DealCountLab.numberOfLines=2;
        _DealCountLab.textAlignment=NSTextAlignmentCenter;
    }
    return _DealCountLab;
}
-(UIButton *)shareBtn{
    if (!_shareBtn) {
        _shareBtn=[UIButton buttonWithType:UIButtonTypeCustom];
        _shareBtn.x=WFCGFloatX(313);
        _shareBtn.y=WFCGFloatY(224);
        _shareBtn.width=WFCGFloatX(62);
        _shareBtn.height=WFCGFloatY(43);
        [_shareBtn handleControlEvent:UIControlEventTouchUpInside withBlock:^{
            NSLog(@"点击");
        }];
        
        
        UIImageView* locationIV=[[UIImageView alloc] init];
        locationIV.image=[UIImage imageNamed:@"new_shop_collcet"];
        locationIV.y=0;
        locationIV.width=locationIV.image.size.width;
        locationIV.height=locationIV.image.size.height;
        locationIV.x=(WFCGFloatX(62)-locationIV.width)/2;
        [_shareBtn addSubview:locationIV];
        
        UILabel* HLable=[[UILabel alloc] init];
        HLable.x=0;
        HLable.y=locationIV.height+3;
        HLable.width=_shareBtn.width;
        HLable.height=WFCGFloatY(17);
        HLable.font=SYSTEMFONT(12);
        HLable.textColor=HEXCOLOR(@"#666666");
        HLable.text=@"收藏";
        HLable.textAlignment=NSTextAlignmentCenter;
        [_shareBtn addSubview:HLable];
        
        
    }
    return _shareBtn;
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self=[super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        [self.contentView addSubview:self.bannerScroll];
//        [self.contentView addSubview:self.titleLab];
//        [self.contentView addSubview:self.DealCountLab];
//        [self.contentView addSubview:self.lineIV];
//        [self.contentView addSubview:self.shareBtn];
//        [self.contentView addSubview:self.levelView];
//        [self.contentView addSubview:self.levelLab];
        
    }
    return self;
}
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index
{
    NSMutableArray* arr=[NSMutableArray new];
    for ( int i=0; i<_imageUrlArr.count; i++)
    {
        [arr addObject:[NSString stringWithFormat:@"%@%@",[_imageUrlArr[i] objectForKey:@"picurl"],kProductImgOriginSuffix]];
    }
    
    PYPhotoBrowseView *photoBroseView = [[PYPhotoBrowseView alloc] init];
    
    // 2.1 设置图片源(UIImageView)数组
    photoBroseView.imagesURL = arr;
    //  photoBroseView.sourceImgageViews = sourceImgageViews;
    photoBroseView.currentIndex=index;
    photoBroseView.frameToWindow=CGRectMake(0, 0, SCREEN_WIDTH, WFCGFloatY(203));
    photoBroseView.frameFormWindow=CGRectMake(0, 0, SCREEN_WIDTH, WFCGFloatY(203));
    
    // 3.显示(浏览)
    [photoBroseView show];
    
}


-(void)layoutSubviews
{
    [super layoutSubviews];

    
    NSMutableArray* arr=[NSMutableArray new];
    for ( int i=0; i<_imageUrlArr.count; i++)
    {
        [arr addObject:[_imageUrlArr[i] objectForKey:@"picurl"]];
    }
    _bannerScroll.imageURLStringsGroup=arr;
    
    _titleLab.x=WFCGFloatX(19);
    _titleLab.y=WFCGFloatY(219);
    _titleLab.width=WFCGFloatX(200);
    _titleLab.height=WFCGFloatY(21);
    _titleLab.text=@"我是店铺名称";
    
    
    
    _DealCountLab.x=WFCGFloatX(250);
    _DealCountLab.y=WFCGFloatY(222);
    _DealCountLab.width=WFCGFloatX(50);
    _DealCountLab.height=WFCGFloatY(40);
    
    _DealCountLab.textAlignment=NSTextAlignmentCenter;
    _DealCountLab.text=@"2\n总销量";
    
    
    [self.levelView removeAllSubviews];
    
    
//    NSString* str=self.detailModel.BuyProductUserInfoModel.xlevel;
//    
//    NSMutableArray * arr = [NSMutableArray arrayWithCapacity:0];
//    // 遍历字符串，按字符来遍历。每个字符将通过block参数中的substring传出
//    [str enumerateSubstringsInRange:NSMakeRange(0, str.length) options:NSStringEnumerationByComposedCharacterSequences usingBlock:^(NSString *substring, NSRange substringRange, NSRange enclosingRange, BOOL *stop) {
//        [arr addObject:substring];
//    }];
//    
//    for (int i=0; i<[arr count]; i++)
//    {
//        UIImageView* iv=[[UIImageView alloc] init];
//        if ([arr[i] isEqualToString:@"A"])
//        {
//            iv.image=[UIImage imageNamed:@"xydj_a"];
//        }
//        if ([arr[i] isEqualToString:@"B"])
//        {
//            iv.image=[UIImage imageNamed:@"xydj_b"];
//        }
//        iv.frame=WFCGRectMake(375-47-20*i, (53-iv.image.size.height)/2, iv.image.size.width, iv.image.size.height);
//        [self.levelView addSubview:iv];
//    }
    
}

@end
